package lesson15homework;

public class Computer 
{
	String brand;
	int year;
	double price;
	boolean isNotebook;
	double hardDriveMemory;
	double freeMemory;
	String operationSystem;
	
	Computer() 
	{
		isNotebook = false;
		operationSystem = "Win Xp";
	}
	
	Computer(int year, double price, double hardDiskMemry, double freeMemory)
	{
		this();
		this.year = year;
		this.price = price;
		this.hardDriveMemory = hardDiskMemry;
		this.freeMemory = freeMemory;
	}
	
	Computer (String brand, int year, double price, boolean isNotebook, double hardDiskMemory, double freeMemory, String operationSystem)
	{
		this(year, price, hardDiskMemory, freeMemory);
		this.isNotebook = isNotebook;
		this.operationSystem = operationSystem;
		this.brand = brand;
	}
	
	
	
	String changeOperationSystem(String newOperationSystem )
	{
		operationSystem = newOperationSystem;
		return operationSystem;
	}

	Double useMemory(double memory)
	{
		if(freeMemory - memory >= 0)
		{
		freeMemory -= memory;
		}
		
		else
		{
			System.out.println("Not enough free memory!");
			System.out.println();
		}
		
		return freeMemory;
	}
	
	int comparePrice(Computer c)
	{
		if (this.price > c.price)
		{
			System.out.println(this.brand + " is more expensive than " + c.brand);
			return -1;
		}
		else 
			if(this.price < c.price)
			{
				System.out.println(this.brand + " is cheaper than " + c.brand);

				return 1;
			}
			else
			{
				System.out.println(this.brand + " and " + c.brand + " have same price");

				return 0;
			}
	}
}







